package com.ailesson.video.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ailesson.video.model.reply.VideoReply;
import com.ailesson.video.model.req.VideoReq;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.ailesson.video.service.VideoService;
import com.ailesson.video.model.req.VideoQueryReq;
import com.ailesson.common.reply.PageResult;
import com.ailesson.common.reply.R;



/**
 * 课程视频
 *
 * @author mac
 * @email mac@gmail.com
 * @date 2024-10-02 10:31:00
 */
@Tag(name = "课程视频模块")
@RestController
@RequestMapping("/admin/vid/video")
public class VideoController {
    @Autowired
    private VideoService videoService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @Operation(summary = "列表")
    @Parameter(name = "params", in = ParameterIn.DEFAULT, description = "查询参数")
   // @RequiresPermissions("video:video:list")
    public R list(@RequestBody VideoQueryReq params){
        PageResult page = videoService.queryPage(params);

        return R.success(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @Operation(summary = "获取信息")
    @Parameter(name = "id",in = ParameterIn.PATH, description = "ID")
   // @RequiresPermissions("video:video:info")
    public R info(@PathVariable("id") Long id){
		VideoReply video = videoService.info(id);

         return R.success(video);
    }

    /**
     * 保存
     */
    @PostMapping("/add")
    @Operation(summary = "添加")
    @Parameter(name = "teacher",in = ParameterIn.QUERY, description = "添加信息")
    //@RequiresPermissions("video:video:save")
    public R add(@RequestBody VideoReq video){
        return R.success(videoService.add(video));
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @Operation(summary = "更新")
    @Parameter(name = "teacher",in = ParameterIn.QUERY, description = "更新信息")
    //@RequiresPermissions("video:video:update")
    public R update(@RequestBody VideoReq video){
		videoService.update(video);

        return R.success();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @Operation(summary = "删除")
    @Parameter(name = "ids",in = ParameterIn.QUERY, description = "删除主键ids")
    //@RequiresPermissions("video:video:delete")
    public R delete(@RequestBody Long[] ids){
		videoService.removeByIds(Arrays.asList(ids));

        return R.success();
    }

}
